Micron Document




Conditional (computer programming)
part 7/26 · 46.2 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
The elseif statement, in the Ada language for example, is simply syntactic sugar for else followed by if. In Ada, the difference is that only one end if is needed, if one uses elseif instead of else followed by if. PHP uses the elseif keywordcite-ref-php-elseif-1-0[1] both for its curly brackets or colon syntaxes. Perl and Ruby provide the keyword elsif to avoid the large number of braces that would be required by multiple if and else statements. Python uses the special keyword elif because structure is denoted by indentation rather than braces, so a repeated use of else and if would require increased indentation after every condition. Some implementations of BASIC, such as Visual Basic,cite-ref-vb-elseif-2-0[2] use ElseIf too. Similarly, the earlier UNIX shells (later gathered up to the POSIX shell syntaxcite-ref-posixshell-3-0[3]) use elif too, but giving the choice of delimiting with spaces, line breaks, or both.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────